package DynamicCrawler;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

public class TestUrl {
    public static String testWsdlConnection(String address) {
        int status = 404;
/*        if (address == null){
            return "";
        }
        if (address.equals("")){
            return "";
        }
        if(!address.substring(0,1).equals("h")){
            return "";
        }*/try {
                URL urlObj = new URL(address);
                HttpURLConnection oc = (HttpURLConnection) urlObj.openConnection();
                oc.setUseCaches(false);
                oc.setConnectTimeout(3000); // 设置超时时间

            status = oc.getResponseCode();// 请求状态
        } catch (IOException e) {
            e.printStackTrace();
        }
        return String.valueOf(status);
            }

    public static void main(String[] args) throws Exception {
        System.out.println(testWsdlConnection("http://db.auto.sina.com.cn/car_manual/1/"));
    }
}
